<?xml version="1.0" encoding="utf-8"?>
<!-- this is an included stylesheet that defines the buttons on most of the pages -->
<xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="utf-8" indent="yes" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" 
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>

<!-- write the buttons in a two-column table with the 
     Home and Save buttons in one column -->
<xsl:template name="writeButtons">
<!-- if writeSave is 1 then write the save button -->
<xsl:param name="writeSave"/>
<!-- specifies the name of the disabled button (there is always one) -->
<xsl:param name="disabled"/>
<table>
<!-- home -->
<tr><td colspan="2" align="center">
	<xsl:call-template name="writeButton">
		<xsl:with-param name="disabled"><xsl:value-of select="$disabled"/></xsl:with-param>
		<xsl:with-param name="script">redirect('/Alpha/Home')</xsl:with-param>
		<xsl:with-param name="label">HomeButton</xsl:with-param>
	</xsl:call-template>
</td></tr>
<!-- view versions and edit versions -->
<tr>
	<td>
	<xsl:call-template name="writeButton">
		<xsl:with-param name="disabled"><xsl:value-of select="$disabled"/></xsl:with-param>
		<xsl:with-param name="script">redirect('/Alpha/ViewVersions')</xsl:with-param>
		<xsl:with-param name="label">VersionsButton</xsl:with-param>
	</xsl:call-template>
	</td>
	<td>
	<xsl:call-template name="writeButton">
		<xsl:with-param name="disabled"><xsl:value-of select="$disabled"/></xsl:with-param>
		<xsl:with-param name="script">redirect('/Alpha/EditVersions')</xsl:with-param>
		<xsl:with-param name="label">EditVersionsButton</xsl:with-param>
	</xsl:call-template>
	</td>
</tr>
<!-- single view and edit single view -->
<tr>
	<td>
	<xsl:call-template name="writeButton">
		<xsl:with-param name="disabled"><xsl:value-of select="$disabled"/></xsl:with-param>
		<xsl:with-param name="script">redirect('/Alpha/View')</xsl:with-param>
		<xsl:with-param name="label">SingleViewButton</xsl:with-param>
	</xsl:call-template>
	</td>
	<td>
	<xsl:call-template name="writeButton">
		<xsl:with-param name="disabled"><xsl:value-of select="$disabled"/></xsl:with-param>
		<xsl:with-param name="script">redirect('/Alpha/EditView')</xsl:with-param>
		<xsl:with-param name="label">EditSingleViewButton</xsl:with-param>
	</xsl:call-template>
	</td>
</tr>
<!-- twin view and edit twin view -->
<tr>
	<td>
	<xsl:call-template name="writeButton">
		<xsl:with-param name="disabled"><xsl:value-of select="$disabled"/></xsl:with-param>
		<xsl:with-param name="script">redirect('/Alpha/TwinView')</xsl:with-param>
		<xsl:with-param name="label">TwinViewButton</xsl:with-param>
	</xsl:call-template>
	</td>
	<td>
	<xsl:call-template name="writeButton">
		<xsl:with-param name="disabled"><xsl:value-of select="$disabled"/></xsl:with-param>
		<xsl:with-param name="script">notImplemented()</xsl:with-param>
		<xsl:with-param name="label">EditTwinViewButton</xsl:with-param>
	</xsl:call-template>
	</td>
</tr>
<!-- facsimile view and edit facsimile view -->
<tr>
	<td>
	<xsl:call-template name="writeButton">
		<xsl:with-param name="disabled"><xsl:value-of select="$disabled"/></xsl:with-param>
		<xsl:with-param name="script">notImplemented()</xsl:with-param>
		<xsl:with-param name="label">FacsimileViewButton</xsl:with-param>
	</xsl:call-template>
	</td>
	<td>
	<xsl:call-template name="writeButton">
		<xsl:with-param name="disabled"><xsl:value-of select="$disabled"/></xsl:with-param>
		<xsl:with-param name="script">notImplemented()</xsl:with-param>
		<xsl:with-param name="label">EditFacsimileViewButton</xsl:with-param>
	</xsl:call-template>
	</td>
</tr>
<!-- save -->
<xsl:if test="$writeSave=1">
	<tr><td>
		<xsl:call-template name="writeButton">
			<xsl:with-param name="disabled"><xsl:value-of select="$disabled"/></xsl:with-param>
			<xsl:with-param name="script">save()</xsl:with-param>
			<xsl:with-param name="label">SaveButton</xsl:with-param>
		</xsl:call-template>
	</td>
	<td>
		<xsl:call-template name="writeButton">
			<xsl:with-param name="disabled"><xsl:value-of select="$disabled"/></xsl:with-param>
			<xsl:with-param name="script">revert()</xsl:with-param>
			<xsl:with-param name="label">RevertButton</xsl:with-param>
		</xsl:call-template>
	</td></tr>
</xsl:if>
</table>
</xsl:template>

<!-- write one button -->
<xsl:template name="writeButton">
	<!-- name of the button to disable -->
	<xsl:param name="disabled"/>
	<!-- url to redirect to -->
	<xsl:param name="script"/>
	<!-- label for button -->
	<xsl:param name="label"/>
	<button type="submit">
		<xsl:if test="$disabled!=$label">
			<xsl:attribute name="class">enabled</xsl:attribute>
			<xsl:attribute name="onclick">
				<xsl:value-of select="$script"/>
			</xsl:attribute>
		</xsl:if>
		<xsl:if test="$disabled=$label">
			<xsl:attribute name="class">disabled</xsl:attribute>
			<xsl:attribute name="disabled">disabled</xsl:attribute>
		</xsl:if>
		<xsl:value-of select="*/strings/string[@name=$label]/@value"/>
	</button>
</xsl:template>

</xsl:stylesheet>